{% extends 'web/base.html' %}
{% load staticfiles %}
{% block base_title %} 支付 {% endblock %}
<!--{% block manifest %}appcache/zuanguan.appcache{% endblock %}-->
{% block base_run %}zuanguan{% endblock %}

{% block base_body %}
{% verbatim %}
<div class="zuan_guan all_bg scroll" id="zuanG">
    <div v-if="loading"></div>
    <div v-else class="load_fix">
        <div class="zuan_center" style="background:none;">
            <div class="ui active centered inline loader red" style="top: 50%;transform: scale(.6)"></div>
        </div>
    </div>

    <div class="zuan_zuan">
        <div class="zuan_zuan_box" v-for="myzuan in zuanAll">
            <div class="zuan_img"><img :src="'http://www.zgtxcj.com/'+myzuan.d_image" alt=""></div>
            <div class="zuan_txt">
                <div class="zuan_name">{{ myzuan.d_name }}</div>
                <div class="zuan_money">{{ myzuan.d_price*myzuan.d_edition }}/{{ myzuan.d_edition }}个月</div>
                <div class="zuan_time">[到期时间：{{ myzuan.dpt_endtime }}]</div>
            </div>
           <a :href="'/xz/login/?phone='+phone+'&pass='+pass+'&redir=tui'">
            <div onclick="localStorage.setItem('tuiid',$(this).attr('tuiid'))" :tuiid="myzuan.d_id" class="zuan_tui">查看推送></div>
            </a>
        </div>
    </div>
</div>
{% endverbatim %}

{% endblock %}
{% block base_script %}
    var zuanguan = new Vue({
        el:'#zuanG',
        data:{
            myUrl:'http://api.zgtxcj.com/',
            zuanAll:[],
            uid:'',
            loading: false,
            phone: localStorage.getItem('phone'),
            pass: localStorage.getItem('pass'),
        },
        methods:{
            getZuan:function(){
                var self=this;
                self.phone=localStorage.getItem('phone');
                self.pass=localStorage.getItem('pass');
                self.uid = localStorage.getItem('uid');
                reqwest({
                    url:'http://api.zgtxcj.com/txcjapi/udia/?tag=dia&u_id='+self.uid,
                    method:'get',
                    type:'json',
                    success:function(resp){
                        for (var u in resp){
                            resp[u]['dpt_endtime']=resp[u]['dpt_endtime'].substring(0,10);
                            if(resp[u]['d_image'].indexOf('|')!=-1){
                                resp[u]['d_image']=resp[u]['d_image'].split('|')[0]
                            }
                        }
                        self.zuanAll=resp; self.loading=true;
                    }
                })
            },
            pan:function(){
                //history.go(0)
                var self = this;
                var ua = window.navigator.userAgent.toLowerCase();
                if(ua.match(/MicroMessenger/i) == 'micromessenger'){
                    self.puanTag="wx";
                    localStorage.setItem('puanTag','wx')
                }else{
                    self.puanTag="xz";
                    localStorage.setItem('puanTag','xz')
                }
                reqwest({
                    url:'http://api.zgtxcj.com/straapi/login/',
                    method:'get',
                    type:'json',
                    data:{
                        username:localStorage.getItem('phone'),
                        token:localStorage.getItem('token'),
                        tag:self.puanTag
                    },
                    success:function(resp){
                        if(resp!=false&&resp!=true){
                            window.localStorage.setItem('token',resp);
                        }
                    }
                })
            },
            run:function () {
                this.getZuan();
                this.pan();
            }
        },
    })
{% endblock %}
